package se.jayway.millionaire.internal.game;

import se.jayway.millionaire.model.game.Answer;
import se.jayway.millionaire.model.game.GameRound;
import se.jayway.millionaire.model.game.GameRoundFinishedException;
import se.jayway.millionaire.model.game.GameSession;
import se.jayway.millionaire.model.game.PlayerChoice;

public class SimplePlayerChoice implements PlayerChoice {

	private final GameRound gameRound;
	private final GameSession gameSession;
	private Answer playerAnswer;

	public SimplePlayerChoice(GameRound gameRound, GameSession gameSession) {
		this.gameRound = gameRound;
		this.gameSession = gameSession;
	}
	
	public Answer getPlayerAnswer() {
		return playerAnswer;
	}

	public void setPlayerAnswer(Answer answer) {
		if (isFinished()) {
			throw new GameRoundFinishedException("Sorry, this game round is finished");
		}
		this.playerAnswer = answer;
	}
	
	public boolean isFinished() {
		return gameRound.isFinished();
	}

	public GameSession getGameSession() {
		return gameSession;
	}

	public GameRound getGameRound() {
		return gameRound;
	}

}
